package com.teemo.sprinboot06mybatiscrud.mapper;

import com.teemo.sprinboot06mybatiscrud.entity.Machine;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MachineMapper {

    @Select("select * from Machine")
    public List<Machine> getAllMachine();

    @Select("delete from Machine where id = #{id}")
    public Integer deleteProductById(Integer id);

    @Select("select max(id)+1 from Machine")
    public Integer getMachineMaxID();


    @Select("select * from Machine where id=#{id}")
    public List<Machine> getMachineById(Integer id);

    @Select("select * from Machine where machine_name=#{machine_name}")
    public List<Integer> getMachineIdByMachineName(String machine_name);

    @Select("select distinct machine_name from Machine")
    public List<String> getDistinctMachineName();

    @Insert("insert into machine(id,machine_name, price, machine_function, machine_features, machine_image)" +
            "values(#{id},#{machine_name}, #{price}, #{machine_function}, #{machine_features}, #{machine_image})")
    public Integer saveMachine(Machine machine);

    public Integer editMachine(Machine machine);
}

